support-for-ie = true

@import 'nib'

// Fonts
$body-font = Helvetica Neue, Open Sans, sans-serif
$mono-font = Menlo, monospace

// Margins
$pad = 40px      // Space between things
$sidepad = 30px  // Padding to the left of the sidebar
$minipad = 20px  // Space for mobile
$vmargin = 10px  // Margin between blocks

// Colors
$offwhite = #f8f8ff
$codebg = #2C3E50
$grey = #9090aa
$txt = #505050
$accent = #4c7731
$line = #e4e7ec * 0.98

// Misc
$shadow-str = 0.1

// Dimensions
$sidebar-width = 230px
$content-width = 550px
$pre-width = 380px

/* ----------------------------------------------------------------------------
 * Fonts
 */

@import url('//fonts.googleapis.com/css?family=Montserrat:700|Open+Sans:300&display=swap')

// ----------------------------------------------------------------------------
// Mixins

scrollbar($bg=white)
  &
    -webkit-overflow-scrolling: touch
  &::-webkit-scrollbar
    width: 15px
    height: 15px
  &::-webkit-scrollbar-thumb
    background: #ddd
    border-radius: 8px
    border: solid 4px $bg
  &:hover::-webkit-scrollbar-thumb
    background: #999
    box-shadow: inset 2px 2px 3px rgba(0, 0, 0, 0.2)

antialias()
  -webkit-font-smoothing: antialiased
  text-rendering: optimizeLegibility

/* ----------------------------------------------------------------------------
 * Base
 */

global-reset()

html, body
  height: 100%

html
  overflow-x: hidden

body, td, textarea, input
  font-family: $body-font
  line-height: 1.6
  font-size: 13px
  color:$txt

  @media (max-width: 480px) /* Mobile */
    font-size: 12px

a
  color: $accent
  text-decoration: none
  &:hover
    color: $accent * 0.8

/* ----------------------------------------------------------------------------
 * Content styling
 */

.content
  p, ul, ol, h1, h2, h3, h4, h5, h6, pre, blockquote
    padding: $vmargin 0
    box-sizing: border-box

  h1, h2, h3, h4, h5, h6
    font-weight: bold
    antialias()

  pre
    font-family: $mono-font

  ul > li
    list-style-type: disc

  ol > li
    list-style-type: decimal

  ul, ol
    margin-left: 20px

  ul > li
    list-style-type: none
    position: relative
    &:before
      content: ''
      display: block
      absolute: left -17px top 7px
      width: 5px
      height: 5px
      border-radius: 4px
      box-sizing: border-box
      background: white
      border: solid 1px $grey

  li > :first-child
    padding-top: 0

  strong, b
    font-weight: bold

  i, em
    font-style: italic
    color: $grey

  code
    font-family: $mono-font
    background: $offwhite
    padding: 1px 3px

  pre > code
    display: block
    background: transparent
    letter-spacing: -1px

  blockquote
    :first-child
      padding-top: 0
    :last-child
      padding-bottom: 0

  table

    margin-top: $vmargin
    margin-bottom: $vmargin
    padding: 0
    border-collapse: collapse
    clear: both

    tr
      border-top: 1px solid #cccccc
      background-color: white
      margin: 0
      padding: 0

      :nth-child(2n)
        background-color: #f8f8f8

      th
        text-align: auto;
        font-weight: bold
        border: 1px solid #cccccc
        margin: 0
        padding: 6px 13px

      td
        text-align: auto;
        border: 1px solid #cccccc
        margin: 0
        padding: 6px 13px

      th, td
        :first-child

          margin-top: 0;
        :last-child
          margin-bottom: 0;



    

/* ----------------------------------------------------------------------------
 * Content
 */

.content-root
  min-height: 90%
  position: relative

.content
  padding-top: $pad - $vmargin
  padding-bottom: $pad
  padding-left: $pad
  padding-right: $pad
  clearfix()

  max-width: 700px

  blockquote
    color: $grey
    text-shadow: 0 1px 0 rgba(white, 0.5)

  h1, h2, h3
    antialias()
    font-family: montserrat
    padding-bottom: 0

    + p, ul, ol
      padding-top: 10px

  h1, h2
    text-transform: uppercase
    letter-spacing: 1px
    font-size: 1.5em

  h3
    font-size: 1.2em

  // Lines
  h1, h2, .big-heading
    padding-top: $pad * 2
    &:before
      display: block
      height: 1px
      position: relative
      top: $pad * -1
      left: $pad * -1
      width: 100%

    @media (max-width: 768px) /* Mobile and tablet */
      padding-top: $minipad * 2
      &:before
        background: $line
        left: $pad * -1
        top: $minipad * -1
        width: 120%

  // Small headings
  h4, h5, .small-heading
    border-bottom: solid 1px rgba(black, 0.07)
    color: $grey
    padding-top: $vmargin * 3
    padding-bottom: 10px

  body:not(.big-h3) & h3
    @extends .content .small-heading
    font-size: 0.9em

  body.big-h3 & h3
    @extends .content .big-heading

  h1:first-child
    padding-top: 0
    &, a, a:visited
      color: $txt
    &:before
      display: none

@media (max-width: 768px) /* Tablet */
  .content
    h4, h5, .small-heading, body:not(.big-h3) & h3
      padding-top: $vmargin * 2

@media (max-width: 480px) /* Mobile */
  .content
    padding: $minipad
    padding-top: $minipad * 2

    h4, h5, .small-heading, body:not(.big-h3) & h3
      padding-top: $vmargin

// ----------------------------------------------------------------------------
// Code blocks

inset-box()
  background: $codebg
  border: solid 1px $codebg*0.95
  border-top: solid 1px $codebg*0.9
  border-left: solid 1px $codebg*0.93
  display: block
  padding: 10px
  border-radius: 2px
  font-size: 14px

  overflow: auto
  scrollbar($codebg)

body.no-literate .content pre > code
  inset-box()

@media (max-width: 1180px) /* Small desktop */
  .content pre > code
    inset-box()
    
// ----------------------------------------------------------------------------
// Buttons

.button
  antialias()
  font-family: montserrat, sans-serif
  letter-spacing: -1px
  font-weight: bold

  display: inline-block
  padding: 3px 25px

  border: solid 2px $accent
  border-radius: 20px

  margin-right: 15px

  &, &:visited
    background: $accent
    color: white
    text-shadow: none

  &:hover
    border-color: #111
    background: #111
    color: white

  &.light
    &, &:visited
      background: transparent
      color: $grey
      border-color: $grey
      text-shadow: none

    &:hover
      border-color: $grey
      background: $grey
      color: white
    
.content
  .button + em
    color: $grey


// ----------------------------------------------------------------------------
// Literate mode content

@media (min-width: 1180px) /* Big desktop */
  body:not(.no-literate)
    .content-root
      background-color: $codebg
      $w = ($sidebar-width + $content-width)
      box-shadow: inset $w 0 white, inset ($w + 1) 0 $line, inset ($w + 10) 0 5px -10px rgba(black, $shadow-str)

// Literate mode
@media (min-width: 1180px) /* Big desktop */
  small-heading()
    margin-left: $pad
    width: $content-width - $pad * 2
    margin-bottom: 3px

    padding-left: 0
    padding-right: 0

  body:not(.no-literate)
    .content
      padding-left: 0
      padding-right: 0

      width: $content-width + $pre-width
      max-width: none

      >
        p, ul, ol, h1, h2, h3, h4, h5, h6, pre, blockquote
          width: $content-width
          box-sizing: border-box
          padding-right: $pad
          padding-left: $pad
        h1, h2, h3
          clear: both
          width: 100%
        pre, blockquote
          width: $pre-width
          padding-left: ($pad/2)
          padding-right: ($pad/2)
          float: right
          clear: right
          +
            p, ul, ol, h4, h5, h6
              clear: both
        p, ul, ol, h4, h5, h6
          float: left
          clear: left

        h4, h5, .small-heading, body:not(.big-h3) & h3
          small-heading()

        table
          margin-left: $pad
          margin-right: $pad
          max-width: $content-width - $pad*2

  body:not(.no-literate):not(.big-h3)
    .content > h3
      small-heading()

// ----------------------------------------------------------------------------
// Header

.header
  background: $offwhite
  text-shadow: 0 1px 0 rgba(white, 0.5)
  border-bottom: solid 1px $line
  padding: 15px 15px 15px $sidepad
  clearfix()

  line-height: 20px
  position: relative

  .left
    float: left

  .right
    text-align: right
    position: absolute
    right: 15px
    top: 15px

    iframe
      display: inline-block
      vertical-align: middle

  h1
    antialias()
    font-weight: bold
    font-family: montserrat, sans-serif
    font-size: 13px

    &, a, a:visited
      color: $grey
    a:hover
      color: $txt

  li a
    font-size: 0.88em
    color: $grey
    display: block

    &:hover
      color: $grey*0.4

  @media (min-width: 480px) /* Tablet & Desktop */
    h1
      float: left

    ul, li
      display: block
      float: left

    ul
      margin-left: -15px

    h1 + ul
      border-left: solid 1px $line
      margin-left: 15px

    li
      border-left: solid 1px rgba(white, 0.5)
      border-right: solid 1px $line
      &:last-child
        border-right: 0

    li a
      padding: 0 15px

@media (max-width: 480px) /* Mobile */
  // Hide extra stuff on mobile
  .right
    display: none

// ----------------------------------------------------------------------------
// Sidebar

.menubar
  antialias()
  .section
    padding: $sidepad $sidepad
    box-sizing: border-box

  .section + .section
    border-top: solid 1px $line

  .section.no-line
    border-top: 0
    padding-top: 0

a.big.button
  display: block
  box-sizing: border-box
  width: 100%
  padding: 10px 20px
  text-align: center

  font-weight: bold
  font-size: 1.1em

  background: transparent
  border: solid 3px $accent
  border-radius: 30px
  font-family: montserrat, sans-serif

  &, &:visited
    color: $accent
    text-decoration: none

  &:hover
    background: $accent
    &, &:visited
      color: white

@media (max-width: 480px) /* Mobile */
  .menubar
    padding: $minipad
    border-bottom: solid 1px $line

@media (max-width: 768px) /* Mobile and tablet */
  .menubar
    display: none

@media (min-width: 768px) /* Desktop */
  .content-root
    padding-left: $sidebar-width

  .menubar
    position: absolute
    left: 0
    top: 0
    bottom: 0
    width: $sidebar-width
    border-right: solid 1px $line

  .menubar.fixed
    position: fixed

    scrollbar()
    overflow-y: auto

.menubar
  font-size: 0.9em

// Menu items
.menu
  ul.level-1 > li + li
    margin-top: 20px

  a
    box-sizing: border-box
    position: relative

    display: block
    padding-top: 1px
    padding-bottom: 1px
    margin-right: ($sidepad * -1)

    &, &:visited
      color: $accent
    &:hover
      color: $accent*0.8

  a.level-1
    font-family: montserrat, sans-serif
    text-transform: uppercase
    font-size: 0.9em
    font-weight: bold
    &, &:visited
      color: $grey
    &:hover
      color: $grey*0.6

  a.level-2
    font-weight: normal

  a.level-3
    font-weight: normal
    font-size: 0.9em
    padding-left: 10px

// ----------------------------------------------------------------------------
// Syntax highlighting

code
  color: #8fa1b3
  .string
    color: #a3be8c
  .number
    color: #d08770
  .init
    color: #219161
  .keyword
    color: #bf616a
    font-weight: bold
  .comment
    color: #65737e
    font-style: italic

// ----------------------------------------------------------------------------

.content
  .large-brief & > h1:first-child + p,
  > p.brief
    font-size: 1.3em
    font-family: Open Sans, sans-serif
    font-weight: 300

// ----------------------------------------------------------------------------

.title-area
  min-height: 100px
  box-sizing: border-box
  antialias()
  text-align: center
  border-bottom: solid 1px $line
  overflow: hidden

  > img.bg
    z-index: 0

    // Start it off screen
    position: absolute
    left: -9999px

  > div
    position: relative
    z-index: 1
  

